#include "player.h"
#include <cstdlib>
#include <stdio.h>
#include <Windows.h>
#include <conio.h>
#define CASH_COLLUMN 15
#define HEALTH_COLLUMN 30
#define MAX_HEALTH 3
#define BANGBANGBANG 0
#define BANG		15
#define CLICK		30
#define TOOK_SHAME -1
Player::Player()
{
	target = NULL;
	cash = 0;
	shame = 0;
	health = 3;
	bangbangbang = 1;
	bang = 2;
	click = 5;
	selectedAction = NULL;
}
//Game Loop functions
void Player::input()
{

}
void update()		//A update used to reset all the values before shooting/splitting
{

}
bool Player::update(Player * a_target, int a_action)
{
	target = a_target;
	selectedAction = NULL;
	switch (a_action)
	{
	case BANGBANGBANG:
		if (bangbangbang > 0)
		{
			bangbangbang--;
			selectedAction = BANGBANGBANG;
		}
		else
		{
			target = NULL;
			return false;
		}
		break;
	case BANG:
		if (bang > 0)
		{
			bang--;
			selectedAction = BANG;
		}
		else
		{
			target = NULL;
			return false;
		}
		break;
	case CLICK:
		if (click > 0)
		{
			click--;
			selectedAction = CLICK;
		}
		else
		{
			target = NULL;
			return false;
		}
		break;
	default:
		target = NULL;
		return false;
		break;
	}
	return true;
}
void Player::draw(int position)
{
	printf("  %s", name);
	COORD point = {CASH_COLLUMN, position};
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), point);
	printf("$%d.00", cash);
	COORD anotherPoint = {HEALTH_COLLUMN, position};
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), anotherPoint);
	for (int i = 0; i < MAX_HEALTH - health; ++i)
		printf("X");
}

void Player::takeShame()
{
	shame++;
	selectedAction = TOOK_SHAME;
}

void Player::setTarget(Player * a_target)
{
	target = a_target;
}